#ifndef DATABASE_FILECACHE_H
#define DATABASE_FILECACHE_H

#include <cerrno>
#include <cstdint>
#include <cstdlib>
#include <map>
#include <mutex>
#include <string>

#include "file.h"
#include "memcache.h"

#define BLOCK_SIZE 16384


namespace Database
{

using std::map;
using std::mutex;
using std::string;

typedef map<string, File *> filelist_map_t;

class FileCache
{
	struct fc_entry
	{
		File f;
		int refs;
	};

public:
	FileCache(const uint64_t cache_size, const uint64_t block_size);
	virtual ~FileCache();

	bool acquire(const char * const pathname);
	void release(const char * const pathname);

private:
	uint64_t cache_size_;

	filelist_map_t files_;
	MemCache cache_;
	mutex mutex_;
};

}	// namespace Database

#endif

